package edu.zju.gis.dbfg.server;

import edu.zju.gis.dbfg.server.interceptor.AuthorityInterceptor;
import edu.zju.gis.dbfg.server.util.SpringUtil;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author Hu
 * @date 2019/8/26
 * 系统启动类
 **/
@EnableTransactionManagement
@SpringBootApplication
@MapperScan({"edu.zju.gis.dbfg.server.mapper"})
public class DbfgServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(DbfgServerApplication.class, args);
        //手动添加 权限拦截器，使得其落后于PageHelperInterceptor注册，优先于PageHelperInterceptor执行
        SqlSessionFactory sqlSessionFactory = SpringUtil.getBean(SqlSessionFactory.class);
        AuthorityInterceptor e = new AuthorityInterceptor();
        sqlSessionFactory.getConfiguration().addInterceptor(e);
    }
}
